﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DconManagerView.xaml.cs" company="R.V.Kasner">
//   Copyright © 2011 R.V.Kasner
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Owen.Terminal.View.DconManager
{
    using System;
    using System.Windows;

    using Owen.Terminal.ViewModel;

    public partial class DconManagerView : IDconManagerView
    {
        private bool isSel;

        public DconManagerView()
        {
            this.InitializeComponent();
            this.cbRequestTypes.SelectionChanged += (s, a) =>
                {
                    this.tbkTitleChanel.Visibility =
                        this.tbxChanel.Visibility = this.cbRequestTypes.SelectedIndex == 1 ? Visibility.Visible : Visibility.Collapsed;
                };
        }

        public event Action Selected;

        public bool IsSelected
        {
            get
            {
                return this.isSel;
            }

            set
            {
                this.isSel = value;
                if (this.isSel) this.RaiseSelected();
            }
        }

        public string Title
        {
            get
            {
                return "Терминал DCON";
            }
        }

        public IViewModel ViewModel
        {
            get
            {
                return this.DataContext as IViewModel;
            }

            set
            {
                this.DataContext = value;
            }
        }

        private void RaiseSelected()
        {
            var a = this.Selected;
            if (a != null) a();
        }
    }
}